package org.evs.odesk.programmingSkills;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author Dmitry Kalachov
 * 
 *         Ross is an event organizer. He has received data regarding the participation of employees in two different
 *         events. Some employees have participated in only one event and others have participated in both events. Ross
 *         now needs to count the number of employees who have taken part in both events. The records received by Ross
 *         consist of employee ids, which are unique. Write a program that accepts the employee ids participating in
 *         each event (the first line relates to the first event and the second line relates to the second event). The
 *         program should print the number of common employee ids in both the events.
 * 
 *         Suppose the following input is given to the program, where each line represents a different event:
 * 
 *         1001,1002,1003,1004,1005
 *         1106,1008,1005,1003,1016,1017,1112
 * 
 *         Now the common employee ids are 1003 and 1005, so the program should give the output as:
 * 
 *         2
 * 
 */
public class Task_BothEventsEmployes {

    public static void main(String[] args) throws IOException {

        BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in));

        int number = 0;

        String firstLine = consoleReader.readLine();
        String secondLine = consoleReader.readLine();

        String[] firstEventEmployesIdsInStringArray = firstLine.split(",");
        String[] secondEventEmployesIdsInStringArray = secondLine.split(",");

        for (String firstId : firstEventEmployesIdsInStringArray) {
            firstId = firstId.trim();
            for (String secondId : secondEventEmployesIdsInStringArray) {
                secondId = secondId.trim();
                if (firstId.equals(secondId)) {
                    number++;
                } else {
                    continue;
                }
            }
        }

        System.out.println(number);

    }

}
